//
//  SecondCell.swift
//  WKWebViewTest
//
//  Created by 刘礼燕 on 2017/9/6.
//  Copyright © 2017年 LLyan. All rights reserved.
//

import UIKit
import SnapKit

class SecondCell: UITableViewCell {

    static var identifier:String {
        return NSStringFromClass(self)
    }
    
    //定义属性
    /**图片*/
    var imgView: UIImageView?
    
    /**名称*/
    var titleLabel:UILabel?
    
    /**说明*/
    var detailLabel:UILabel?
    
    override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        self.selectionStyle = UITableViewCellSelectionStyle.none
        self.loadCellSubViews()
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    override func awakeFromNib() {
        super.awakeFromNib()
        // Initialization code
        
        
    }

    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)

        // Configure the view for the selected state
    }

    func loadCellSubViews(){
        
        imgView = UIImageView()
        imgView?.backgroundColor = UIColor.green
        self.addSubview(imgView!)
        imgView?.snp.makeConstraints({ (make) in
            make.left.top.equalTo(10)
            make.bottom.equalTo(-10)
            make.width.equalTo(self.bounds.height*2/3)
        })
        
        titleLabel = UILabel()
        titleLabel?.textAlignment = NSTextAlignment.left
        titleLabel?.textColor = UIColor.blue
        titleLabel?.font = UIFont.systemFont(ofSize: 18)
        self.addSubview(titleLabel!)
        titleLabel?.snp.makeConstraints({ (make) in
            make.left.equalTo((imgView?.snp.right)!).offset(10)
            make.right.equalTo(-10)
            make.top.equalTo(10)
            make.height.equalTo(30)
        })
        
        detailLabel = UILabel()
        detailLabel?.textAlignment = .left
        detailLabel?.textColor = UIColor.lightGray
        detailLabel?.font = UIFont.systemFont(ofSize: 15)
        detailLabel?.numberOfLines = 3
        self.addSubview(detailLabel!)
        detailLabel?.snp.makeConstraints({ (make) in
            make.top.equalTo((titleLabel?.snp.bottom)!).offset(10)
            make.left.equalTo((imgView?.snp.right)!).offset(10)
            make.right.equalTo(-10)
            make.bottom.equalTo(-10)
        })
        

        
    }
    
    
    
}
